package interfaces;
import com.toedter.calendar.JDateChooser;

import gestion.Actividades;
import gestion.Usuarios;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import dominio.Actividad;
import dominio.Usuario;
import excepciones.DAOExcepcion;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaActividad extends javax.swing.JDialog {
	private JLabel jLabelNombre;
	private JLabel jLabelDescripcion;
	private JLabel jLabelFechaInicio;
	private JLabel jLabelPosibilidadFraccionar;
	private JLabel jLabelEstadoComment2;
	private JLabel jLabelEstadoComment;
	private JTextField jTextFieldEstado;
	private JTextField jTextFieldPlazasTotales;
	private JLabel jLabelPlazasTotales;
	private JButton jButtonCancelar;
	private JButton jButtonGuardar;
	private JDateChooser jDateChooserAlarmaFecha2;
	private JDateChooser jDateChooserAlarmaFecha1;
	private JTextArea jTextAreaCondiciones;
	private JTextField jTextFieldCampoEspecial3;
	private JTextField jTextFieldCampoEspecial2;
	private JTextField jTextFieldCampoEspecial1;
	private JTextField jTextFieldAlarmaPlazas2;
	private JTextField jTextFieldAlarmaPlazas1;
	private JTextField jTextFieldEmail;
	private JComboBox jComboBoxPosibilidadFraccionar;
	private JDateChooser jDateChooserFechaFin;
	private JDateChooser jDateChooserFechaInicio;
	private JComboBox jComboBoxTipo;
	private JTextArea jTextAreaConcepto;
	private JTextArea jTextAreaDescripcion;
	private JTextField jTextFieldPrecio;
	private JTextField jTextFieldNombre;
	private JLabel jLabelCondiciones;
	private JLabel jLabelCampoEspecial3;
	private JLabel jLabelCampoEspecial2;
	private JLabel jLabelCampoEspecial1;
	private JLabel jLabelEstado;
	private JLabel jLabelAlarmaFecha2;
	private JLabel jLabelAlarmaFecha1;
	private JLabel jLabelAlarmaPlazas2;
	private JLabel jLabelAlarmaPlazas1;
	private JLabel jLabelEmail;
	private JLabel jLabelConcepto;
	private JLabel jLabelPrecio;
	private JLabel jLabelFechaFin;
	private JLabel jLabelTipo;
	
	private Actividad actividad = new Actividad();
	private Actividades gestionActividades = new Actividades();

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				VentanaActividad inst = new VentanaActividad(frame);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaActividad(JFrame frame) {
		super(frame);
		initGUI();
	}
	
	public VentanaActividad() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			{
				GridBagLayout thisLayout = new GridBagLayout();
				thisLayout.columnWidths = new int[] {130, 10, 240};
				thisLayout.columnWeights = new double[] {0.0, 0.0, 0.0};
				thisLayout.rowHeights = new int[] {0, 0, 40, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 40, 40};
				thisLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
				getContentPane().setLayout(thisLayout);
				this.setTitle("ESN Office - Actividad");
				{
					jLabelNombre = new JLabel();
					getContentPane().add(jLabelNombre, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelNombre.setText("Nombre *");
				}
				{
					jLabelDescripcion = new JLabel();
					getContentPane().add(jLabelDescripcion, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelDescripcion.setText("Descripción");
				}
				{
					jLabelTipo = new JLabel();
					getContentPane().add(jLabelTipo, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelTipo.setText("Tipo *");
				}
				{
					jLabelFechaInicio = new JLabel();
					getContentPane().add(jLabelFechaInicio, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelFechaInicio.setText("Fecha Inicio *");
				}
				{
					jLabelFechaFin = new JLabel();
					getContentPane().add(jLabelFechaFin, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelFechaFin.setText("Fecha Fin *");
				}
				{
					jLabelPosibilidadFraccionar = new JLabel();
					getContentPane().add(jLabelPosibilidadFraccionar, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelPosibilidadFraccionar.setText("Posibilidad Fraccionar *");
				}
				{
					jLabelPrecio = new JLabel();
					getContentPane().add(jLabelPrecio, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelPrecio.setText("Precio *");
				}
				{
					jLabelConcepto = new JLabel();
					getContentPane().add(jLabelConcepto, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelConcepto.setText("Concepto de precio *");
				}
				{
					jLabelEmail = new JLabel();
					getContentPane().add(jLabelEmail, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelEmail.setText("E-email de organizador *");
				}
				{
					jLabelAlarmaPlazas1 = new JLabel();
					getContentPane().add(jLabelAlarmaPlazas1, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelAlarmaPlazas1.setText("Alarma Plazas 1");
				}
				{
					jLabelAlarmaPlazas2 = new JLabel();
					getContentPane().add(jLabelAlarmaPlazas2, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelAlarmaPlazas2.setText("Alarma Plazas 2");
				}
				{
					jLabelAlarmaFecha1 = new JLabel();
					getContentPane().add(jLabelAlarmaFecha1, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelAlarmaFecha1.setText("Alarma Fecha 1");
				}
				{
					jLabelAlarmaFecha2 = new JLabel();
					getContentPane().add(jLabelAlarmaFecha2, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelAlarmaFecha2.setText("Alarma Fecha 2");
				}
				{
					jLabelEstado = new JLabel();
					getContentPane().add(jLabelEstado, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelEstado.setText("Estado *");
				}
				{
					jLabelCampoEspecial1 = new JLabel();
					getContentPane().add(jLabelCampoEspecial1, new GridBagConstraints(0, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelCampoEspecial1.setText("Campo Especial 1");
				}
				{
					jLabelCampoEspecial2 = new JLabel();
					getContentPane().add(jLabelCampoEspecial2, new GridBagConstraints(0, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelCampoEspecial2.setText("Campo Especial 2");
				}
				{
					jLabelCampoEspecial3 = new JLabel();
					getContentPane().add(jLabelCampoEspecial3, new GridBagConstraints(0, 18, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelCampoEspecial3.setText("Campo Especial 3");
				}
				{
					jLabelCondiciones = new JLabel();
					getContentPane().add(jLabelCondiciones, new GridBagConstraints(0, 19, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelCondiciones.setText("Condiciones");
				}
				{
					jTextFieldNombre = new JTextField();
					getContentPane().add(jTextFieldNombre, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldPrecio = new JTextField();
					getContentPane().add(jTextFieldPrecio, new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextAreaDescripcion = new JTextArea();
					getContentPane().add(jTextAreaDescripcion, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextAreaConcepto = new JTextArea();
					getContentPane().add(jTextAreaConcepto, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					ComboBoxModel jComboBoxTipoModel = 
							new DefaultComboBoxModel(
									new String[] { "Viaje", "Tandem" });
					jComboBoxTipo = new JComboBox();
					getContentPane().add(jComboBoxTipo, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jComboBoxTipo.setModel(jComboBoxTipoModel);
				}
				{
					jDateChooserFechaInicio = new JDateChooser("dd/MM/yyyy", "##-##-####", '-');
					getContentPane().add(jDateChooserFechaInicio, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jDateChooserFechaFin = new JDateChooser("dd/MM/yyyy", "##-##-####", '-');
					getContentPane().add(jDateChooserFechaFin, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					ComboBoxModel jComboBoxPosibilidadFraccionarModel = 
							new DefaultComboBoxModel(
									new String[] { "No", "Sí" });
					jComboBoxPosibilidadFraccionar = new JComboBox();
					getContentPane().add(jComboBoxPosibilidadFraccionar, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jComboBoxPosibilidadFraccionar.setModel(jComboBoxPosibilidadFraccionarModel);
				}
				{
					jTextFieldEmail = new JTextField();
					getContentPane().add(jTextFieldEmail, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldAlarmaPlazas1 = new JTextField();
					getContentPane().add(jTextFieldAlarmaPlazas1, new GridBagConstraints(2, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldAlarmaPlazas2 = new JTextField();
					getContentPane().add(jTextFieldAlarmaPlazas2, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldCampoEspecial1 = new JTextField();
					getContentPane().add(jTextFieldCampoEspecial1, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldCampoEspecial2 = new JTextField();
					getContentPane().add(jTextFieldCampoEspecial2, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldCampoEspecial3 = new JTextField();
					getContentPane().add(jTextFieldCampoEspecial3, new GridBagConstraints(2, 18, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextAreaCondiciones = new JTextArea();
					getContentPane().add(jTextAreaCondiciones, new GridBagConstraints(2, 19, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jDateChooserAlarmaFecha1 = new JDateChooser("dd/MM/yyyy", "##-##-####", '-');
					getContentPane().add(jDateChooserAlarmaFecha1, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jDateChooserAlarmaFecha2 = new JDateChooser("dd/MM/yyyy", "##-##-####", '-');
					getContentPane().add(jDateChooserAlarmaFecha2, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jButtonGuardar = new JButton();
					getContentPane().add(jButtonGuardar, new GridBagConstraints(2, 20, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
					jButtonGuardar.setText("Guardar");
					jButtonGuardar.setPreferredSize(new java.awt.Dimension(90, 23));
					jButtonGuardar.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
								try {
									jButtonGuardarActionPerformed(evt);
								} catch (HeadlessException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								} catch (DAOExcepcion e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
						}
					});
				}
				{
					jButtonCancelar = new JButton();
					getContentPane().add(jButtonCancelar, new GridBagConstraints(2, 20, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
					jButtonCancelar.setText("Cancelar");
					jButtonCancelar.setPreferredSize(new java.awt.Dimension(90, 23));
					jButtonCancelar.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							jButtonCancelarActionPerformed(evt);
						}
					});
				}
				{
					jLabelPlazasTotales = new JLabel();
					getContentPane().add(jLabelPlazasTotales, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelPlazasTotales.setText("PlazasTotales *");
				}
				{
					jTextFieldPlazasTotales = new JTextField();
					getContentPane().add(jTextFieldPlazasTotales, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jTextFieldEstado = new JTextField();
					getContentPane().add(jTextFieldEstado, new GridBagConstraints(2, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
				}
				{
					jLabelEstadoComment = new JLabel();
					getContentPane().add(jLabelEstadoComment, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelEstadoComment.setText("0 (cerrada), 1 (abierta),");
				}
				{
					jLabelEstadoComment2 = new JLabel();
					getContentPane().add(jLabelEstadoComment2, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
					jLabelEstadoComment2.setText("2 (completa)");
				}
			}
			this.setSize(480, 640);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void jButtonCancelarActionPerformed(ActionEvent evt) {
		System.out.println("jButtonCancelar.actionPerformed, event="+evt);
		this.dispose();
	}
	
	private void jButtonGuardarActionPerformed(ActionEvent evt) throws HeadlessException, DAOExcepcion {
		System.out.println("jButtonGuardar.actionPerformed, event="+evt);
		
		//TODO auto-increment para el id
		//actividad.setIdactividad(idactividad);
		actividad.setNombre(jTextFieldNombre.getText());
		actividad.setDescripcion(jTextAreaDescripcion.getText());
		actividad.setTipo(jComboBoxTipo.getSelectedIndex());
		actividad.setFechainicio(jDateChooserFechaInicio.getDate());
		actividad.setFechafin(jDateChooserFechaFin.getDate());
		actividad.setPosibilidadfraccionar(jComboBoxPosibilidadFraccionar.getSelectedIndex());
		double precio = -1;
		if (jTextFieldPrecio.getText().length() != 0) 
			precio = Double.parseDouble(jTextFieldPrecio.getText());
		actividad.setPrecio(precio);
		actividad.setConcepto(jTextAreaConcepto.getText());
		Usuarios gestionUsuarios = new Usuarios();
		Usuario usuario = new Usuario();
		if(gestionUsuarios.comprobarUsuarioPorEmail(jTextFieldEmail.getText())){ // 0-esncard, 1-email
			usuario = gestionUsuarios.recuperarUsuarioPorEmail(jTextFieldEmail.getText());
			actividad.setUsuario(usuario);
		}
		else {
			JOptionPane error = new JOptionPane();
			error.showMessageDialog(null, "No existe el usuario con este email", "Error", JOptionPane.ERROR_MESSAGE);
		}
		int plazasTotales = -1;
		if (jTextFieldPlazasTotales.getText().length() != 0) 
			plazasTotales = Integer.parseInt(jTextFieldPlazasTotales.getText());
		actividad.setPlazastotales(plazasTotales);
		int alarmaPlazas1 = -1;
		if (jTextFieldAlarmaPlazas1.getText().length() != 0) 
			alarmaPlazas1 = Integer.parseInt(jTextFieldAlarmaPlazas1.getText());
		actividad.setAlarmaplazas1(alarmaPlazas1);
		int alarmaPlazas2 = -1;
		if (jTextFieldAlarmaPlazas2.getText().length() != 0) 
			alarmaPlazas2 = Integer.parseInt(jTextFieldAlarmaPlazas2.getText());
		actividad.setAlarmaplazas2(alarmaPlazas2);
		actividad.setAlarmafecha1(jDateChooserAlarmaFecha1.getDate());
		actividad.setAlarmafecha2(jDateChooserAlarmaFecha2.getDate());
		int estado = -1;
		if (jTextFieldEstado.getText().length() != 0) 
			estado = Integer.parseInt(jTextFieldEstado.getText());
		actividad.setEstado(estado);
		actividad.setCampoespecial1(jTextFieldCampoEspecial1.getText());
		actividad.setCampoespecial2(jTextFieldCampoEspecial2.getText());
		actividad.setCampoespecial3(jTextFieldCampoEspecial3.getText());
		actividad.setCondiciones(jTextAreaCondiciones.getText());
		
		if(gestionActividades.comprobarActividadNuevaEsCorrecta(actividad)) {
			if (gestionActividades.anadirActividad(actividad))
				this.dispose();
			else {
				JOptionPane error = new JOptionPane();
				error.showMessageDialog(null, "Fallo en guardado de datos", "Error", JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	

}
